home *** CD-ROM | disk | FTP | other *** search
- /* fread.c, from p. 429 of Turbo C Bible */
- #include <stdio.h>
- main()
- {
- int numread;
- FILE *infile;
- char filename[80], buffer[80];
- printf("Enter name of a text file: ");
- gets(filename);
- /* Open the file for reading */
- if ((infile = fopen(filename, "rb")) == NULL)
- {
- printf("fopen failed.\n");
- exit(0);
- }
- /* Read 80 characters and display the */
- /* buffer */
- numread = fread((void *)buffer, sizeof(char), 80, infile);
- printf("Read these %d characters:\n %s\n", numread, buffer);
- }